package week5;

import java.util.Scanner;

public class project1 {
        private double radius;
        private static final double PI = Math.PI;

        public project1(double radius) {
            this.radius = Math.max(radius, 0);
        }
        public double getRadius() {
            return radius;
        }
        public void setRadius(double radius) {
            this.radius = Math.max(radius, 0);
        }
        public double calculateArea() {
            return PI * radius * radius;
        }
        public static void main(String[] args) {
            project1 circle = new project1(5);
            System.out.println("圆的半径: " + circle.getRadius());
            System.out.println("圆的面积: " + circle.calculateArea());
            circle.setRadius(10);
            System.out.println("修改后的半径: " + circle.getRadius());
            System.out.println("修改后的面积: " + circle.calculateArea());
            project1 invalidCircle = new project1(-3);
            System.out.println("负数半径处理后: " + invalidCircle.getRadius());
            System.out.println("对应面积: " + invalidCircle.calculateArea());
        }
    }
